(define (scan-out-defines procedure-body)
  (define (iter body res1 res2)
    (cond ((null? body)
           (cons res1 res2))
          ((definition? (car body))
           (iter (cdr body) res1 (cons (car body) res2)))
          (else
           (iter (cdr body) (cons (car body) res1) res2))))
  (let ((sepa (iter procedure-body '() '())))
    (let ((body (car sepa)) (defines (cdr sepa)))
      (if (null? defines)
          procedure-body
          (let ((define-vars (map definition-variable defines))
                (define-vals (map definition-value defines)))
            (list (make-let (map (lambda (var) (list var ''*unassigned*))
                                 define-vars)
                            (append (map (lambda (var val)
                                           (list 'set! var val))
                                         define-vars
                                         define-vals)
                                    body))))))))